﻿var $p=new Object();
$p.openWins=new Array();
$p.nextWinNum=0;
$p.winReturnValue=null;
$p.tabnum=0;
$(function () {
	try{$(".ui-table").uTable();}catch(e){}
})
var $w={
	listFlesh:false,
	docevents:[],
	toLogin:function(){
		window.parent.parent.parent.$w.alertMsg("操作超时，请重新登录!");
		window.parent.parent.parent.location.href=ctx+'/platform/index.jsp';
	},
	addTab:function(ops){
		var tabid="";
		var add=true;
		if(ops.id)
			tabid=ops.id;
		else{
			tabid="mainTab"+$p.tabnum;
			$p.tabnum=$p.tabnum+1;
		}
		var maintab=$('#main_Tabs');
		var tabs=maintab.tabs("tabs");
		var gettab;
		if(tabs.length==0){//为了ie兼用模式下宽度错位问题
			$("#main_Tabs").width($('#ui_main_tab_frame').layout('panel', 'center').panel('panel').width());
			$("#main_Tabs").children().width($('#ui_main_tab_frame').layout('panel', 'center').panel('panel').width());
		}else if(tabs.length>=6){
			maintab.tabs('close',maintab.tabs("getTab",0).panel('options').title);
		}
		$(tabs).each(function(){
				var ts=this.panel('options').title;
				if($(ts).attr("id")==tabid){
					//add=false;gettab=this;
					maintab.tabs('close',ts);
					return false;
				}
		});
		if (!add){
			maintab.tabs('select', gettab.panel('options').title);
			maintab.tabs('update', {
				tab: gettab,
				options: {
					title: "<a id='"+tabid+"'>"+ops.title+"</a>"
				}
			});
			if(ops.fresh){
				if(ops.iframe){
					var iframe=$("iframe",gettab.panel("panel"));
					iframe.attr("src",ops.href);
				}else{
					maintab.tabs('getSelected').panel('refresh',ops.href);
				}
			}
		} else {
			var icon='';if(ops.iconUrl)icon=ops.iconUrl;
			if(ops.iframe){
				maintab.tabs('add',{
					title:"<a id='"+tabid+"'>"+ops.title+"</a>",
					content:'<iframe src="" width="100%" height="100%" frameborder="0" loadUrl="'+ops.href+'"></iframe>',
					iconUrl:icon,
					closable:true
				});
			}else{
				maintab.tabs('add',{
					title:"<a id='"+tabid+"'>"+ops.title+"</a>",
					href:ops.href,
					iconUrl:icon,
					closable:true
				});
				
			}
			bindTabEven();
		}
	},
	getTabObj:function(){
		return $('#main_Tabs');
	},
	getTab:function(title){
		return $('#main_Tabs').tabs("getTab",title);
	},
	selectTab:function(title){
		$('#main_Tabs').tabs('select', title);
	},
	openWin:function(ops){
		$w.setWinReturn(null);
		$w.listFlesh=false;
		var wid="";
		if(ops.id)
			wid=ops.id;
		else{
			$p.nextWinNum=$p.nextWinNum+1;
			wid="_MailWinDiv"+$p.nextWinNum;
		}
		var bl=false;
		for(var i=0;i<$p.openWins.length;i++) 
	  {
	  	if($p.openWins[i]==wid){
	  		bl=true;
	  		break;
	  	}
	  }
	  
  	if(!bl){
  		$p.openWins.add(wid);
			var ic="icon_win";
			var doAfterClose;
			if(ops.afterClose)doAfterClose=ops.afterClose;
			else{
				doAfterClose=function(re){
					if($w.listFlesh)
						$w.reloadCurrTab();
				}
			}
			if(ops.icon)ic=ops.icon;
			//$("iframe",$('#'+wid)).contents().find("body").empty();
			var closefun=function(){$p.openWins.remove(wid);$("iframe",$('#'+wid)).attr("src","about:blank");$w.clearDocEvent();if(navigator.userAgent.indexOf("MSIE")>0) {CollectGarbage();}$('#'+wid).window('destroy');$('#'+wid).remove();ui_winTasks_del(wid);doAfterClose($w.getWinReturn());};
			if($("#ui_main_center")[0])
				$("<div id='"+wid+"'></div>").appendTo($("#ui_main_center"));
			else
				$("<div id='"+wid+"'></div>").appendTo(document.body);
			var wintitle=ops.title || '新窗口';
			if(ops.iframe){
				var h=ops.h;
				if(ops.maximized){
					if($("#ui_main_center")[0])h=$("#ui_main_center").height();
					else h=$(window).height();
				}
				$('#'+wid).window({
					title:wintitle,
					iconCls:ic,
			    width:ops.w,
			    height:ops.h,
			    modal:ops.modal,
			    inline:true,
			    collapsible:ops.collapsible,
			    minimizable:ops.minimizable,
			    maximizable:ops.maximizable,
			    resizable:ops.resizable,
			    maximized:ops.maximized,
			    content:'<iframe id="'+wid+'_Iframe" name="'+wid+'_Iframe" src="'+ops.url+'" width="100%" height="'+(h-40)+'" frameborder="0" scrolling="no"></iframe>',
			    onClose:closefun
				});
			}else{
				$('#'+wid).window({
					title:wintitle,
					iconCls:ic,
			    width:ops.w,
			    height:ops.h,
			    modal:ops.modal,
			    inline:true,
			    collapsible:ops.collapsible,
			    minimizable:ops.minimizable,
			    maximizable:ops.maximizable,
			    resizable:ops.resizable,
			    maximized:ops.maximized,
			    onClose:closefun,
			    extractor:function(data){return checkpanelData_(data);}
				});
				$('#'+wid).window("refresh",ops.url);
			}
			
			if(!ops.modal){
				$(".ui-winTasks").show();
				ui_winTasks_add(wintitle,wid);
			}
		}else{
  		if(ops.fresh){
					if(ops.iframe)$("iframe",$('#'+wid)).attr("src",ops.url);
					else $('#'+wid).window("refresh",ops.url);
			}
			else $('#'+wid).window("open");
  	}
			
	},
	openDialog:function(ops){
		ops.modal=true;
		if(!ops.collapsible)
			ops.collapsible=false
		if(!ops.minimizable)
		ops.minimizable=false;
		if(!ops.maximizable)
		ops.maximizable=false;
		this.openWin(ops);
	},
	reloadCurrTab:function(href){
		if(href)
			$w.currTab().panel('refresh',href);
		else
			$w.currTab().panel('refresh');
	},
	reloadCurrWin:function(href){
		if(href)
			$w.currWin().window('refresh',href);
		else
			$w.currWin().window('refresh');
	},
	closeCurrWin:function(returnvalue){
		if(returnvalue)
			$w.setWinReturn(returnvalue);
		this.currWin().window('close');
	},
	getWin:function(wid){
		for(var i=0;i<$p.openWins.length;i++) 
	  {
	  	if($p.openWins[i]==wid){
	  		return $("#"+wid).window();
	  	}
	  }
	},
	closeWin:function(wid){
		for(var i=0;i<$p.openWins.length;i++) 
	  {
	  	if($p.openWins[i]==wid){
	  		$("#"+wid).window('close');
	  		break;
	  	}
	  }
	},
	setWinReturn:function(returnvalue){
		$p.winReturnValue=returnvalue;
	},
	getWinReturn:function(){
		return $p.winReturnValue;
	},
	currTab:function(tabid){
		if(tabid)
			return $('#'+tabid).tabs('getSelected');
		else
			return $('#main_Tabs').tabs('getSelected');
	},
	currWin:function(){
		var cw;
		var czi=0;
		for(i=0;i<$p.openWins.length;i++){
			var zindex=parseInt($("#"+$p.openWins[i]).window("panel").css("zIndex"));
			if(zindex>czi){
				czi=zindex;
				cw=$("#"+$p.openWins[i]);
			}
		}
		return cw;
	},
	closeTab:function(title){
		$('#main_Tabs').tabs('close',title);
	},
	closeCurrTab:function(){
		$('#main_Tabs').tabs('close',$w.currTab().panel('options').title);
	},
	findBasePanel:function(tar,type){
		var par=tar.parent();
		if(!par[0])return null;
		if(par.hasClass("panel-body"))
		return par;
		else return $w.findBasePanel(par,type);
	},
	execForm:function(ops){
		var mform;
		if(ops && ops.form)
			mform=ops.form;
		else
			mform=$w.currForm(ops?ops.target:'');
		if(!mform.form("validate"))
			return false;
		if(ops && ops.pageNum)
			$getByName("pageNum",mform).val(ops.pageNum);
		var actionurl=mform.attr("action");
		if(actionurl.indexOf(ctx)!=0)actionurl=ctx+actionurl;
		
		mform.attr("action",actionurl);
		if(ops && ops.target && ops.target!='undefined'){
				try{
					ops.target.panel("options").extractor=function(data){return panelextractor_(data);}
					ops.target.panel('refresh',{href:actionurl,data:mform.serializeArray()});
				}catch(e){ops.target.panel({href:actionurl,data:mform.serializeArray(),extractor:function(data){return panelextractor_(data);}});}
		}else{
			var pobj=$w.findBasePanel(mform);
			if(!pobj)
				mform.get(0).submit();
			else{
				pobj.panel("options").extractor=function(data){
					return panelextractor_(data);
				}
				pobj.panel('refresh',{href:actionurl,data:mform.serializeArray()});
		}}
	},
	execUrl:function(url,edata,target){
		if(target && target!='undefined'){
			if(target=='window'){
				$w.currWin().window("options").extractor=function(data){return panelextractor_(data);}
				$w.currWin().window('refresh', {href:url,data:edata});  
			}else{
				try{
					target.panel("options").extractor=function(data){return panelextractor_(data);}
					target.panel('refresh',{href:url,data:edata});
				}catch(e){target.panel({href:url,data:edata,extractor:function(data){return panelextractor_(data);}});}
			}
		}
		else{
			$w.currTab().panel("options").extractor=function(data){return panelextractor_(data);}
			$w.currTab().panel('refresh',{href:url,data:edata});
		}
	},
	execPage:function(ops){
		var mform;
		if(ops && ops.form)mform=ops.form;
		else
		 mform=$w.currForm();
		if(ops && ops.target && ops.target!='undefined'){
				var panel=$("#"+ops.target);
				var olddata=panel.panel('options').data;
				olddata=$w.updateFormPageInfo(olddata,ops);
				try{panel.panel('refresh',{href:panel.panel('options').href,data:olddata});}catch(e){panel.panel({href:panel.panel('options').href,data:olddata});}
		}
		else{
			var actionurl=mform.attr("action");
			if(actionurl.indexOf(ctx)==-1)actionurl=ctx+actionurl;
			if(ops && ops.pageNum)$("[name='pageNum']",mform).val(ops.pageNum);
			if(ops && ops.pageSize)$("[name='pageSize_']",mform).val(ops.pageSize);
			var pobj=$w.findBasePanel(mform);
			mform.attr("action",actionurl);
			if(!pobj)
				mform[0].submit();
			else
				pobj.panel('refresh',{href:actionurl,data:mform.serializeArray()});
			
		}
	},
	doForm:function(ops){
		var mform;
		if(ops && ops.form)mform=ops.form;
		else
		 mform=$w.currForm(ops?ops.target:'');
		if(!mform.form("validate"))
			return false;
		var dobackcall=function(json){
			if(json){
				$w._afterupdate(json.jsonpageinfo_);
				if(json && json.resetForm_=='true')mform.get(0).reset();
			}
			if(ops.callback){ops.callback(json);}
		}
		var actionurl=mform.attr("action");
		if(actionurl.indexOf(ctx)==-1)actionurl=ctx+actionurl;
		if(mform[0].enctype.toLowerCase()=="multipart/form-data"){
			$w._iframeCallback(mform,dobackcall);
			mform[0].action=actionurl
			mform[0].submit();
		}else{
			$.ajax({
				type: 'POST',
				url:actionurl,
				data:mform.serializeArray(),
				dataType:"json",
				cache: false,
				success: dobackcall,
				error: $w.ajaxError
			});
		}
		
		return false;
	},
	doUrl:function(url,datas,callback){
		var dobackcall=function(json){
			if(json){
				$w._afterupdate(json.jsonpageinfo_);
				if(json && json.resetForm_=='true')mform.get(0).reset();
			}
			if(callback)
				callback(json);
		}
		$.ajax({
			type: 'POST',
			url:url,
			data:datas,
			dataType:"json",
			cache: false,
			success: dobackcall,
			error: $w.ajaxError
		});
		return false;
	},
	doWinForm:function(callback){
		var mform=$w.currWinForm();
		$w.doForm({form:mform,callback:callback});
	},
	panelLoad:function(pan,parms){
		pan.panel("options").extractor=function(data){return panelextractor_(data);}
		pan.panel("refresh",parms);
	},
	updateFormPageInfo:function(datas,ops){
		if(datas &&$.isArray(datas)){
				for(i=0;i<datas.length;i++){
					if(ops && ops.pageNum){if(datas[i].name=='pageNum')datas[i].value=ops.pageNum;}
					if(ops && ops.pageSize){if(datas[i].name=='pageSize_')datas[i].value=ops.pageSize;}
				}
			}else{
				if(!datas)datas={};
				if(ops && ops.pageNum)datas.pageNum=ops.pageNum;
				if(ops && ops.pageSize)datas.pageSize_=ops.pageSize;
			}
			return datas;
	},
	currTabForm:function(){
		if(this.isMainIndex())
		return $("form", this.currTab());
		else return $("form");
	},
	isMainIndex:function(){
		if(window.location.href.indexOf(ctx+"/platform/UI/index.jsp")!=-1)return true;
		else return false;
	},
	currWinForm:function(){
		return $("form", this.currWin().window("panel"));
	},
	currForm:function(target){
		if(target && target!="undefined"){
			if(typeof target=="string"){
				if(target=='window')
					return $w.currWinForm();
				else if(target=='_thisFrame')
					return $("form");
				else
					return $("form", $("#"+target));
			}
			else
				return $("form",target);
		}else
			return $w.currTabForm();
	},
	alertMsg:function(text,title){
		$.messager.alert(title || '系统信息提示',text,'warning');
	},
	
	infoMsg:function(text,title){
		$.messager.show({
				title:title || '系统信息提示',
				msg:"<span class='infoMsgicon'></span>"+text,
				showType:'slide',
				style:{
					right:'',
					top:document.body.scrollTop+document.documentElement.scrollTop,
					bottom:''
				}
			});
	},
	correctMsg:function(text,title){
		$.messager.show({
				title:title || '系统信息提示',
				msg:"<span class='okMsgicon'></span>"+text,
				showType:'slide',
				style:{
					right:'',
					top:document.body.scrollTop+document.documentElement.scrollTop,
					bottom:''
				}
			});
	},
	errorMsg:function(text,title){
		$.messager.alert(title || '系统错误提示',text,'error');
	},
	confirmMsg:function(text,callback,title){
		$.messager.confirm(title || '系统信息提示', text, function(r){
				callback(r);
			});
	},
	ajaxError:function(xhr, ajaxOptions, thrownError){
		var txt=xhr.responseText; if(txt)$w.errorMsg(txt);
	}
	,_afterupdate: function (jsonpage){
		if(jsonpage){
			if(jsonpage.stateCode=='200'){
				$w.toLogin();
				return false;
			}
			$(jsonpage).each(function(){
				if(this.script_)
					window.eval(this.script_);
				else if(this.showInfoMsg_)
					window.parent.parent.parent.$w.infoMsg(this.showInfoMsg_);
				else if(this.showErrorMsg_)
					window.parent.parent.parent.$w.errorMsg(this.showErrorMsg_);
				else if(this.showAlertMsg_)
					window.parent.parent.parent.$w.alertMsg(this.showAlertMsg_);
				else if(this.showOkMsg_)
					window.parent.parent.parent.$w.correctMsg(this.showOkMsg_);
			});
		}
	},
	addDocEvent:function(n,f){
		var obj=new Object();
		obj.name=n;
		obj.fun=f;
		$w.docevents[$w.docevents.length]=obj;
		$(document).bind(n,f);
	},
	clearDocEvent:function(){
		for(i=0;i<$w.docevents.length;i++){
			$(document).unbind($w.docevents[i].name);
		}
	},
	_iframeCallback:function(mform,callback){
		var $form = mform, $iframe = $("#callbackframe");
		if ($iframe.size() == 0) {
			$iframe = $("<iframe id='callbackframe' name='callbackframe' src='about:blank' style='display:none'></iframe>").appendTo("body");
		}
		if(!mform[0].ajax) {
			$form.append('<input type="hidden" name="ajax" value="1" />');
		}
		mform[0].target = "callbackframe";
		
		$document = $(document);
	
		$document.trigger("ajaxStart");
		
		$iframe.bind("load", function(event){
			$iframe.unbind("load");
			$document.trigger("ajaxStop");
			
			if ($iframe[0].src == "javascript:'%3Chtml%3E%3C/html%3E';" || // For Safari
				$iframe[0].src == "javascript:'<html></html>';") { // For FF, IE
				return;
			}
	
			var doc = $iframe[0].contentDocument || $iframe[0].document;
	
			// fixing Opera 9.26,10.00
			if (doc.readyState && doc.readyState != 'complete') return; 
			// fixing Opera 9.64
			if (doc.body && doc.body.innerHTML == "false") return;
		   
			var response;
			
			if (doc.XMLDocument) {
				// response is a xml document Internet Explorer property
				response = doc.XMLDocument;
			} else if (doc.body){
				try{
					response = $iframe.contents().find("body").html();
					response = jQuery.parseJSON(response);
				} catch (e){ // response is html document or plain text
					response = doc.body.innerHTML;
				}
			} else {
				// response is a xml document
				response = doc;
			}
			
			callback(response);
		});
	}
}

$p.openWins.add=function(wid){
	$p.openWins[$p.openWins.length]=wid;
}

$p.openWins.remove=function(wid) 
{ 
    for(var i=0;i<this.length;i++) 
    { 
        if(this[i]==wid){
        	
        	for(var j=(i+1);j<this.length;j++){
        		this[j-1]=this[j];
        		
        	}
        	break
        }
    }
    if(this.length>=1)
    this.length-=1;
}

//绑定tab右键
function bindTabEven() {
	/*双击关闭TAB选项卡*/
	$(".tabs-inner").dblclick(function(){
		var subtitle = $(this).children(".tabs-closable").text();
		$('#main_Tabs').tabs('close',subtitle);
	})
	/*为选项卡绑定右键*/
	$(".tabs-inner").bind('contextmenu',function(e){
		$('#mm_tab').menu('show', {
			left: e.pageX,
			top: e.pageY+8
		});

		var subtitle =$(this).children(".tabs-closable").text();

		$('#mm_tab').data("currtab",subtitle);
		$('#main_Tabs').tabs('select',subtitle);
		return false;
	});
}


function ui_winTasks_add(title,wid){
	var taskdiv=$("<div class='ui-winTasks-li' id='ui-winTasks"+wid+"'><span class='ui-winTasks-icon' onclick=\"$('#"+wid+"').window('open')\"></span><span class='ui-winTasks-title' onclick=\"$('#"+wid+"').window('open')\">"+title+"</span><span class='ui-winTasks-close' onclick=\"ui_winTasks_del('"+wid+"')\">×</span></div>");
	taskdiv.appendTo($(".ui-winTasks"))
	taskdiv.mouseover(function(e){taskdiv.addClass('ui-winTasks-over')}).mouseout(function(e){taskdiv.removeClass('ui-winTasks-over')});
}
function ui_winTasks_del(wid){
	$("#"+wid).window('close');
	$("#ui-winTasks"+wid).remove();
	if($(".ui-winTasks-li").length<=0)
		$(".ui-winTasks").hide();
}
function panelextractor_(data){
	var checkd=checkpanelData_(data);
	var pattern = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
	var matches = pattern.exec(checkd);
	if (matches){
			return matches[1];	// only extract body content
	}else{
			return checkd;
	}
}
function checkpanelData_(data){
    data = data + "";
	if(data[0] == "{"){
		try{
			var rejson=jQuery.parseJSON(data);
			if(rejson.jsonpageinfo_.stateCode=='200'){
				$w.toLogin();
				return "<div style='margin:5px'>操作超时，正在为您跳转登录...</div>";
			}
		}catch(e){}
	}
	return data;
}
function $getByName(name,parent){
	var obj;
	if($w.isMainIndex()){
		if(parent)obj=parent;else obj=$w.currTab();
		return $("[name='"+name+"']",obj);
	}else return $("[name='"+name+"']",parent);
}
function $getById(id,parent){
	var obj;
	if($w.isMainIndex()){
	if(parent)obj=parent;else obj=$w.currTab();
	return $("#"+id,obj);
	}else return $("#"+id);
}
function $selAllTbBoxs(obj){
	var $grid = $(obj).parent().parent().parent().parent();
	$("[name='primaryKey_']",$grid).each(function(){
		if(obj.checked){
			this.checked=true;
		}
		else{
			this.checked=false;
		}
		})
}
function $limitLen(obj,len){
	if(obj.value.length>len)obj.value=obj.value.substring(0,len);
}

function $findParent(target,obj){
	var par=$(obj).parent();
	if(!par[0])return null;
	if(par.get(0).tagName.toLowerCase()==target.toLowerCase())
	return par;
	else return $findParent(target,par.get(0));
}
function $selUserTree(callback){
	window.parent.parent.$w.openDialog({url:ctx+"/platform/common/userTree.jsp",title:'选择用户',iframe:true,w:280,h:350,afterClose:function(re){
			if(callback)callback(re);
		}});
}

function IsExt(url,opt)
{  
		var sTemp; 
		var b=false; 
		var s=opt.toUpperCase().split("|");  
		for (var i=0;i<s.length ;i++ ) 
		{ 
			sTemp=url.substr(url.length-s[i].length-1); 
			sTemp=sTemp.toUpperCase();
			s[i]="."+s[i];
			if (s[i]==sTemp)
			{
				b=true;
				break;
			}
		}
		return b;
}

//utable
(function($){
 $.fn.uTable = function(args){
	var tbsthis=$(this);
	var pageList=['10','20','30','50','100','150','200'];
	var ops={pageinfo:true,pagego:true,sizesel:true};
	if(tbsthis.attr("data-options")){
		var opsd={};
		try{opsd=window.eval('({' + tbsthis.attr("data-options") + '})');}catch(ew){alert("data-options格式错误："+tbsthis.attr("data-options"));}
		ops=$.extend({},ops,opsd);
	}
	var pcount=0;
	if(ops.showPage){
		if(!ops.pageNum)ops.pageNum=1;
		if(!ops.pageSize)ops.pageSize=20;
		var m=parseInt(ops.total)%parseInt(ops.pageSize);
		if(m!=0)
			pcount=Math.ceil(parseInt(ops.total)/parseInt(ops.pageSize))||1;
		else
			pcount=parseInt(ops.total)/parseInt(ops.pageSize);
	}
	
	return this.each(function() {
		var tbthis=$(this);
		$("tbody>tr",tbthis).mouseover(function() {$(this).children().addClass("ui_tdover");}).mouseout(function() {$(this).children().removeClass("ui_tdover");}).click(function() {
			$("tbody>tr",tbthis).children().removeClass("ui_tdsel");
			$(this).children().addClass("ui_tdsel");
			});
		if(ops.showPage){
			var pn=parseInt(ops.pageNum);
			var lastnum=pn-1;if(lastnum<=0)lastnum=1;
			var nextnum=pn+1;if(nextnum>pcount)nextnum=pcount;
			var psize=parseInt(ops.pageSize);
			var str="<div class='ui-pagination'>";
			if(ops.sizesel){
				str+="<div class='pageList'><select name='page_size' onchange=\"uTable_changesize(this,'"+ops.form+"','"+ops.target+"')\">";
				for(i=0;i<pageList.length;i++){
					var seled="";var afteraddbl=false;
					if(psize==parseInt(pageList[i]))seled="selected";
					else if(psize>parseInt(pageList[i])){if(i<pageList.length-1 && psize<parseInt(pageList[i+1]))afteraddbl=true;else if(i==pageList.length-1)afteraddbl=true;}
					else if(psize<parseInt(pageList[i]) && i==0)str+="<option value='"+psize+"' selected>"+psize+"</option>";
					str+="<option value='"+pageList[i]+"' "+seled+">"+pageList[i]+"</option>";
					if(afteraddbl)
						str+="<option value='"+psize+"' selected>"+psize+"</option>";
				}
				str+="</select></div>";
			}
			str+="<div class='pagebu'>";
			if(parseInt(ops.pageNum)>1)str+="<span class='buspan page_first' title='第一页' onclick=\"uTable_page(1,'"+ops.form+"','"+ops.target+"')\"></span><span class='buspan page_last' title='上一页' onclick=\"uTable_page("+lastnum+",'"+ops.form+"','"+ops.target+"')\"></span>";else str+="<span class='buspan page_first_a' title='第一页'></span><span class='buspan page_last_a' title='上一页'></span>";
			if(parseInt(ops.pageNum)<pcount)str+="<span class='buspan page_next' title='下一页' onclick=\"uTable_page("+nextnum+",'"+ops.form+"','"+ops.target+"')\"></span><span class='buspan page_final' title='最后一页' onclick=\"uTable_page("+pcount+",'"+ops.form+"','"+ops.target+"')\"></span>";else str+="<span class='buspan page_next_a' title='下一页'></span><span class='buspan page_final_a' title='最后一页'></span>";
			str+="<span class='buspan page_reload' title='刷新当前页' onclick=\"uTable_reload('"+ops.form+"','"+ops.target+"')\"></span>";
			if(ops.pagego)str+="<span class='page_txt'>跳到</span><span class='page_input'><input name='go_page' style='width:30px'></span><span class='page_go' onclick=\"uTable_go(this,"+pcount+",'"+ops.form+"','"+ops.target+"')\"></span><span class='page_txt'>页</span>";
			str+="</div>";
			if(ops.pageinfo)str+="<div class='pageinfo'>第"+ops.pageNum+"页/共"+pcount+"页,共"+ops.total+"条记录</div>";
			str+="</div>";
			tbthis.after(str);
		}
	});
};

})(jQuery);
function uTable_reload(fform,ftarget){
	if(fform!="undefined")$w.execPage({form:$("#"+fform),target:ftarget});
	else $w.execPage({target:ftarget});
}
function uTable_page(pnum,fform,ftarget){
	if(fform!="undefined")$w.execPage({pageNum:pnum,form:$("#"+fform),target:ftarget});
	else $w.execPage({pageNum:pnum,target:ftarget});
}
function uTable_go(obj,pcount,fform,ftarget){
	var v=$("[name='go_page']",$(obj).prev()).val();
	if(v!=""){
		if(!isNaN(v)){
			if(parseInt(v)>pcount)v=pcount;
			else if(parseInt(v)<=0)v="1";
			uTable_page(v,fform,ftarget);
		}
	}
}
function uTable_changesize(obj,fform,ftarget){
	if(fform!="undefined")$w.execPage({pageNum:'1',pageSize:obj.value,form:$("#"+fform),target:ftarget});
	else $w.execPage({pageNum:'1',pageSize:obj.value,target:ftarget});
}

function fixWidth(percent){
	return $(window).width()*percent;
}
function inputMonery(obj){
		$(obj).val($(obj).val().replace(/[^0-9.]/g,''));
}
function inputNumber(obj){
		$(obj).val($(obj).val().replace(/[^0-9]/g,''));
}
function isMobile(str){
	var isMobile=/^(?:13\d|15\d|18\d)\d{5}(\d{3}|\*{3})$/;
	return isMobile.test(str)
}